import { type AdminType, type User_info } from "@/types/Admin"

export const Token = {
    Set_token: (token: string) => {
        localStorage.setItem("token", token)
    },
    Get_token: () => {
        return localStorage.getItem("token")
    },
    Re_move: () => {
        return localStorage.removeItem("token")
    },

}

export const Admin_info = {
    Set_info: (data: AdminType) => {

        localStorage.setItem('admin', JSON.stringify(data))
    },
    Get_info: () => {

        if (!localStorage.getItem('admin')) {
            return ''
        } else {
            return JSON.parse(localStorage.getItem('admin') as string)

        }
    },
    Remove_info: () => {
        localStorage.removeItem("admin")
        localStorage.removeItem('token')
        return ''
    }
}

export const user_info = {
    Set_info: (data: User_info) => {
        localStorage.setItem('user', JSON.stringify(data))
    },
    Set_token: (token: string) => {
        localStorage.setItem("token", token)
    },
    Get_token: () => {
        return localStorage.getItem("token")
    },
    Re_move: () => {
        localStorage.removeItem("token")
        localStorage.removeItem('user')
        return ''
    },
    Get_info: () => {

        if (!localStorage.getItem('user')) {
            return ''
        } else {
            return JSON.parse(localStorage.getItem('user') as string)

        }
    },
}